﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HttpFileServer
{
    public class MiMeType
    {
        readonly static string[] _mimeytpesStr ={  
                    ".htm|text/html",
                    ".css|text/css",
                    ".js|text/javascript",
                    ".json|text/javascript",
                    ".msi|text/mspg-legacyinfo",
                    ".msp|text/mspg-legacyinfo",
                    ".txt|text/plain",
                    ".srt|text/plain",
                    ".srt|text/srt",
                    ".vtt|text/vtt",
                    ".srt|text/vtt",
                    ".xml|text/xml",
                    ".f4m|text/xml",
                    ".ttml|text/xml",
                    ".js|text/x-javascript",
                    ".json|text/x-javascript",
                    ".json|text/x-json",
                    ".f4m|application/f4m+xml",
                    ".gz|application/gzip",
                    ".js|application/javascript",
                    ".json|application/json",
                    ".doc|application/msword",
                    ".docx|application/msword",
                    ".dot|application/msword",
                    ".dotx|application/msword",
                    ".pdf|application/pdf",
                    ".dfxp|application/ttaf+xml",
                    ".m3u8|application/vnd.apple.mpegurl",
                    ".zip|application/zip",
                    ".7z|application/x-7z-compressed",
                    ".plj|application/x-aim",
                    ".z|application/x-compress",
                    ".7z|application/x-compress-7z",
                    ".arj|application/x-compressed",
                    ".exe|application/x-dosexec",
                    ".tar|application/x-gtar",
                    ".gz|application/x-gzip",
                    ".gz|application/x-gzip-compressed",
                    ".js|application/x-javascript",
                    ".m3u8|application/x-mpegurl",
                    ".exe|application/x-msdos-program",
                    ".dll|application/x-msdos-program",
                    ".msi|application/x-msi",
                    ".msp|application/x-msp",
                    ".msi|application/x-ole-storage",
                    ".msp|application/x-ole-storage",
                    ".rar|application/x-rar",
                    ".rar|application/x-rar-compressed",
                    ".exe|application/x-sdlc",
                    ".sdlc|application/x-sdlc",
                    ".swf|application/x-shockwave-flash",
                    ".xap|application/x-silverlight-app",
                    ".srt|application/x-subrip",
                    ".tar|application/x-tar",
                    ".zip|application/x-zip",
                    ".zip|application/x-zip-compressed",
                    ".3gp|video/3gpp",
                    ".3gpp|video/3gpp",
                    ".3gp|video/3gpp2",
                    ".3gpp|video/3gpp2",
                    ".avi|video/avi",
                    ".f4f|video/f4f",
                    ".f4m|video/f4m",
                    ".flv|video/flv",
                    ".ts|video/mp2t",
                    ".m3u8|video/mp2t",
                    ".mp4|video/mp4",
                    ".m4v|video/mp4",
                    ".mpg|video/mpeg",
                    ".mpeg|video/mpeg",
                    ".m3u|video/mpegurl",
                    ".m3u8|video/mpegurl",
                    ".mp4|video/mpg4",
                    ".m4v|video/mpg4",
                    ".avi|video/msvideo",
                    ".mov|video/quicktime",
                    ".qt|video/quicktime",
                    ".webm|video/webm",
                    ".flv|video/x-flash-video",
                    ".flv|video/x-flv",
                    ".mp4|video/x-mp4",
                    ".m4v|video/x-mp4",
                    ".m3u|video/x-mpegurl",
                    ".m3u8|video/x-mpegurl",
                    ".mp4|video/x-mpg4",
                    ".m4v|video/x-mpg4",
                    ".asf|video/x-ms-asf",
                    ".wmv|video/x-ms-wmv",
                    ".avi|video/x-msvideo",
                    ".3gp|audio/3gpp",
                    ".3gpp|audio/3gpp",
                    ".3gp|audio/3gpp2",
                    ".3gpp|audio/3gpp2",
                    ".mp3|audio/mp3",
                    ".m4a|audio/mp4",
                    ".mp4|audio/mp4",
                    ".m4a|audio/mp4a-latm",
                    ".mp4|audio/mp4a-latm",
                    ".mp3|audio/mpeg",
                    ".m4a|audio/mpeg4-generic",
                    ".mp4|audio/mpeg4-generic",
                    ".m3u|audio/mpegurl",
                    ".m3u8|audio/mpegurl",
                    ".webm|audio/webm",
                    ".wav|audio/wav",
                    ".mp3|audio/x-mpeg",
                    ".m3u|audio/x-mpegurl",
                    ".m3u8|audio/x-mpegurl",
                    ".wma|audio/x-ms-wma",
                    ".wav|audio/x-wav",
                    ".mp3|ilm/tm",
                    ".gif|image/gif",
                    ".gfa|image/gif",
                    ".ico|image/icon",
                    ".cur|image/icon",
                    ".jpg|image/jpg",
                    ".jpeg|image/jpg",
                    ".jpg|image/jpeg",
                    ".jpeg|image/jpeg",
                    ".png|image/png",
                    ".apng|image/png",
                    ".tif|image/tiff",
                    ".tiff|image/tiff",
                    ".ico|image/vnd.microsoft.icon",
                    ".cur|image/vnd.microsoft.icon",
                    ".webp|image/webp",
                    ".ico|image/x-icon",
                    ".cur|image/x-icon",
                    ".flv|flv-application/octet-stream"
        };
        public static string GetMiMeType(string ext)
        {
            switch (ext.ToLower()){
                case ".3gp": return "video/3gpp";
                case ".3gpp": return "video/3gpp";
                case ".7z": return "application/x-7z-compressed";
                case ".apng": return "image/png";
                case ".arj": return "application/x-compressed";
                case ".asf": return "video/x-ms-asf";
                case ".avi": return "video/avi";
                case ".css": return "text/css";
                case ".cur": return "image/vnd.microsoft.icon";
                case ".dfxp": return "application/ttaf+xml";
                case ".dll": return "application/x-msdos-program";
                case ".doc": return "application/msword";
                case ".docx": return "application/msword";
                case ".dot": return "application/msword";
                case ".dotx": return "application/msword";
                case ".exe": return "application/x-dosexec";
                case ".f4f": return "video/f4f";
                case ".f4m": return "application/f4m+xml";
                case ".flv": return "video/flv";
                case ".gfa": return "image/gif";
                case ".gif": return "image/gif";
                case ".gz": return "application/gzip";
                case ".htm": return "text/html";
                case ".html": return "text/html";
                case ".ico": return "image/icon";
                case ".jpeg": return "image/jpeg";
                case ".jpg": return "image/jpeg";
                case ".js": return "text/javascript";
                case ".json": return "text/javascript";
                case ".m3u": return "video/mpegurl";
                case ".m3u8": return "video/mpegurl";
                case ".m4a": return "audio/mp4";
                case ".m4v": return "video/mp4";
                case ".mov": return "video/quicktime";
                case ".mp3": return "audio/mp3";
                case ".mp4": return "video/mp4";
                case ".mpeg": return "video/mpeg";
                case ".mpg": return "video/mpeg";
                case ".msi": return "application/x-msi";
                case ".pdf": return "application/pdf";
                case ".plj": return "application/x-aim";
                case ".png": return "image/png";
                case ".qt": return "video/quicktime";
                case ".rar": return "application/x-rar";
                case ".sdlc": return "application/x-sdlc";
                case ".srt": return "text/srt";
                case ".swf": return "application/x-shockwave-flash";
                case ".tar": return "application/x-tar";
                case ".tif": return "image/tiff";
                case ".tiff": return "image/tiff";
                case ".ts": return "video/mp2t";
                case ".ttml": return "text/xml";
                case ".txt": return "text/plain";
                case ".vtt": return "text/vtt";
                case ".wav": return "audio/wav";
                case ".webm": return "video/webm";
                case ".webp": return "image/webp";
                case ".wma": return "audio/x-ms-wma";
                case ".wmv": return "video/x-ms-wmv";
                case ".xap": return "application/x-silverlight-app";
                case ".xml": return "text/xml";
                case ".z": return "application/x-compress";
                case ".zip": return "application/x-zip-compressed";
                default: return "*/*";
            }
        }
    }
}
